<template>
  <div class="orderlist">
    <el-form :inline="true" :model="dataForm">
      <el-form-item label="订单编号">
        <el-input v-model="params.order_code" placeholder="订单编号"></el-input>
      </el-form-item>
      <el-form-item label="到店时间">
        <el-date-picker v-model="params.date" value-format="yyyy-MM-dd" placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button @click="getListMsg()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table border :data="serviceList" row-key="Id">
      <el-table-column header-align="center" align="center" label="商品信息">
        <template slot-scope="scope">
          <div v-if="scope.row.child_order_list.length>0">
            <el-popover placement="top-start" trigger="hover">
              <a :href="scope.row.child_order_list[0].goods_img" target="_blank" title="查看最大化图片"><img :src="scope.row.child_order_list[0].goods_img" style="width: 300px; height: 300px" /></a>
              <img slot="reference" @click="$openImg(scope.row.child_order_list[0].goods_img)" :src="scope.row.child_order_list[0].goods_img" style="width: 50px; height: 50px; cursor: pointer" />
            </el-popover>
            {{scope.row.child_order_list[0].goods_title}}
          </div>
        </template>
      </el-table-column>
      <el-table-column header-align="center" align="center" label="客户信息">
        <template slot-scope="scope">
          <div>
            姓名:{{scope.row.nickname}}
          </div>
          <div>
            手机号:{{scope.row.mobile}}
          </div>
        </template>
      </el-table-column>
      <el-table-column header-align="center" align="center" label="订单编号">
        <template slot-scope="scope">
          <div>
            {{scope.row.order_code}}
          </div>
        </template>
      </el-table-column>
      <el-table-column header-align="center" align="center" label="到店时间">
        <template slot-scope="scope">
          <div>
            {{scope.row.appointment_time}}
          </div>
        </template>
      </el-table-column>
      <el-table-column header-align="center" align="center" label="客户要求" show-overflow-tooltip>
        <template slot-scope="scope">
          {{scope.row.require}}
        </template>
      </el-table-column>

    </el-table>
    <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="params.page" :page-sizes="[10, 20, 50, 100]" :page-size="params.limit" :total="totalPage" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
  </div>
</template>

<script>
import seviceApi from '@/api/serviceApi.js'
export default {
  data () {
    return {
      dataForm: {},
      serviceList: [],
      params: {
        page: 1,
        limit: 10,
        order_code: null,
        date: ''
      },
      totalPage: 0
    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    getList () {
      console.log('this.params', this.params)
      seviceApi.getReservationList(this.params).then(res => {
        if (res && res.status == 200) {
          this.serviceList = res.data.page.list
          this.totalPage = res.data.page.totalCount
          console.log(this.serviceList)
        }
      })
    },
    getListMsg () {
      this.params.page = 1
      this.getList()
    },

    sizeChangeHandle (val) {
      this.params.limit = val
      this.getList()
    },
    currentChangeHandle (val) {
      this.params.page = val
      this.getList()
    },
    sizeChangeHandle (val) {
      this.params.limit = val
      this.getList()
    }
  }

}
</script>

<style>
</style>
